package com.hpdf.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.hpdf.constants.ErrorType;
import com.hpdf.dao.DomeDao;
import com.hpdf.domain.TbDCarinfo;
import com.hpdf.domain.param.TbDCarinfoRequest;
import com.hpdf.service.DomeService;
import com.hpdf.utils.exception.BizException;
import com.hpdf.utils.web.resultbean.BizResult;
import com.hpdf.utils.web.resultbean.PageBean;

@Service("com.hpdf.service.impl.DomeServiceImpl")
public class DomeServiceImpl implements DomeService {
	private static final Logger logger = Logger.getLogger(DomeServiceImpl.class);
	@Autowired
	private DomeDao domeDao;

	@Override
	public BizResult<TbDCarinfo> queryCarinfo(TbDCarinfo carinfo) {
		logger.info("---bein 查询车辆基本信息..入参=" + JSONObject.toJSONString(carinfo));
		TbDCarinfo tbDCarinfo = new TbDCarinfo();
		try {
			if (carinfo != null) {

				tbDCarinfo = domeDao.queryCarinfo(carinfo);
				// throw new
				// BizException(ErrorType.PARAMM_NULL.getCode(),"入参不能为空");
			} else {
				throw new BizException(ErrorType.PARAMM_NULL.getCode(), "入参不能为空");
			}
		} catch (Exception e) {
			throw new BizException(ErrorType.PARAMM_NULL.getCode(), "入参不能为空");
			// logger.info("查询车辆基本信息异常");
			// throw new BizException(ErrorType.BIZ_ERROR.getCode(),"入参不能为空");
			// e.printStackTrace();
		}

		return new BizResult<TbDCarinfo>(tbDCarinfo);
	}

	public BizResult<PageBean<TbDCarinfo>> queryCarinfoForPage(TbDCarinfoRequest tbDCarinfoRequest) throws Exception {
		PageBean<TbDCarinfo> pageBean = domeDao.queryCarinfoForList(tbDCarinfoRequest);
		return new BizResult<PageBean<TbDCarinfo>>(pageBean);
	}

	@Override
	public int insertInCarinfo(TbDCarinfo carinfo) {
		
		return domeDao.insertInCarinfo(carinfo);
	}

}
